<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表格展示</title>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid black;
            padding: 8px;
            text-align: left;
        }
    </style>
</head>
<body>
    <h1>表格展示</h1>
    <table id="data-table"></table>

    <script>
        // 通过Flask传递的参数，使用Jinja2模板语法
        var data = {{ data | safe }};

        // 获取要插入数据的table元素
        var table = document.getElementById('data-table');

        // 遍历数据并生成表格
        data.forEach(function(row, rowIndex) {
            var tr = document.createElement('tr');
            row.forEach(function(cell) {
                var cellElement = document.createElement(rowIndex === 0 ? 'th' : 'td');
                cellElement.textContent = cell;
                tr.appendChild(cellElement);
            });
            table.appendChild(tr);
        });
    </script>
</body>
</html>
